//
//  UIBarButtonItem+HBWHomeViewController.m
//  hbw
//
//  Created by Mac on 16/2/17.
//  Copyright © 2016年 mac. All rights reserved.
//

#import "UIBarButtonItem+CustomItem.h"
//#import "ApisButton.h"

@implementation UIBarButtonItem (HBWHomeViewController)

+ (instancetype)itemWithImage:(NSString *)image hightImage:(NSString *)hightImage target:(id)target action:(SEL)action
{
    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
//    button.frame = CGRectMake(0, 0, 50, 80);
//    button.backgroundColor = [UIColor redColor];
    [button setBackgroundImage:[UIImage imageNamed:image] forState:UIControlStateNormal];
    [button setBackgroundImage:[UIImage imageNamed:image] forState:UIControlStateHighlighted];
    //  button.size=button.currentBackgroundImage.size;
//    button.backgroundColor = [UIColor orangeColor];
    [button sizeToFit];
    [button addTarget:target action:action forControlEvents:UIControlEventTouchUpInside];
    return [[self alloc]initWithCustomView:button];
}


//+ (instancetype)titleItemWithImageName:(NSString *)image hightImage:(NSString *)hightImg target:(id)target action:(SEL)action title:(NSString *)text{
//    
//    ApisButton *button = [ApisButton buttonWithType:UIButtonTypeCustom];
//        button.frame = CGRectMake(0, 20, 35, 50);
////        button.backgroundColor = [UIColor purpleColor];
//    [button setImage:[UIImage imageNamed:image] forState:UIControlStateNormal];
//    [button setImage:[UIImage imageNamed:image] forState:UIControlStateHighlighted];
//    //  button.size=button.currentBackgroundImage.size;
//    
//    
//    [button setTitle:text forState:UIControlStateNormal];
//    button.titleLabel.font = [UIFont systemFontOfSize:10];
//    
//    button.imageSize = CGSizeMake(20, 15);
//    button.spaceWithImageAndTitle = 3;
////    button.imageView.frame = CGRectMake(5, 5, 20, 20);
////    button.titleLabel.frame = CGRectMake(5, 40, 45, 30);
////    
////    
////    CGFloat superW = button.width;
////    button.imageView.center = CGPointMake(superW/2.f, 30);
////    button.titleLabel.center = CGPointMake(superW/2.f, superW/2.f+10+15);
////    [button sizeToFit];
//    [button addTarget:target action:action forControlEvents:UIControlEventTouchUpInside];
//    return [[self alloc]initWithCustomView:button];
//}


+ (id)itemWithTitle:(NSString *)title titleColor:(UIColor *)color{
    
    UIBarButtonItem *leftItem = [[UIBarButtonItem alloc] initWithTitle:title style:UIBarButtonItemStylePlain target:nil action:nil];
    NSMutableDictionary *attr = [[NSMutableDictionary alloc] init];
    attr[NSForegroundColorAttributeName] = color;
    [leftItem setTitleTextAttributes:attr  forState:UIControlStateNormal];
    return leftItem;
}

@end
